// 把普通数组 转成树状数据
export function transformData(arr, root) {
  const newArr = []

  arr.forEach(item => {
    if (item.pid === root) {
      const children = transformData(arr, item.id)
      if (children.length) {
        item.children = children
      }
      newArr.push(item)
    }
  })
  return newArr
}

